﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace BPMS.Core
{
    /// <summary>
    /// 数据字段
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
    public class DataFieldAttribute : Attribute
    {
        /// <summary>
        /// 字段名称
        /// </summary>
        public string FieldName { get; set; }

        /// <summary>
        /// 字段类型
        /// </summary>
        public DbType FieldType { get; set; }

        /// <summary>
        /// 是否主键
        /// </summary>
        public bool IsPrimaryKey { get; set; }

        /// <summary>
        /// 是否标识列
        /// </summary>
        public bool IsIdentity { get; set; }

        public DataFieldAttribute()
        { }

        public DataFieldAttribute(string name, DbType type)
        {
            this.FieldName = name;
            this.FieldType = type;
        }

        public DataFieldAttribute(string name, DbType type, bool isPK, bool isIdentity)
            : this(name, type)
        {
            this.IsPrimaryKey = isPK;
            this.IsIdentity = isIdentity;
        }
    }
}
